package com.tom.de;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Import(AuthorityProperties.class)
//设置优先级最高
@Order(Ordered.HIGHEST_PRECEDENCE)
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private AuthorityProperties authorityProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new AuthorityInterceptor())
                //拦截路径
                .addPathPatterns(authorityProperties.getPathPatterns())
                //排除路径
                .excludePathPatterns(authorityProperties.getExcludePathPatterns());

    }
}

